<?php
defined( 'ABSPATH' ) || exit;

get_header();
?>

<div class="container hers_news">
	<?php
	if(have_posts()){
		while(have_posts()){
			the_post();
			$startTime=get_post_meta(get_the_ID(), "start_time", $single = true);
			$endTime=get_post_meta(get_the_ID(), "end_time", $single = true);
			$currentDate=wp_date("Y-m-d");//wordpress使用达特（）函数会差8小时
	?>
	<ul class="recent-posts animate-box">
		<li class="col-sm-4">
			<div class="border-img">
			<img loading="lazy" src="<?php 
			if(has_post_thumbnail()){
				the_post_thumbnail_url('medium');
				echo '" alt="';
				the_title();
				}else{
					echo '/images/no-pic-news.jpg" alt="赫思模特';
				}
			?>">
			</div>
		</li>
		<li class="col-sm-8">
			<div class="recent-post-desc">
				<h2><?php the_title();?><i class="iconfont 
				<?php 
				if($startTime>$currentDate){
					echo 'icon-jingqingqidai " style="color:#44C662;"';
				}elseif($endTime>=$currentDate){
					echo 'icon-afoot " style="color:red;"';}else{
						echo 'icon-finished " style="color:#848484;"';}
				?>
				></i></h2>
				<p class="post-cat"><?php echo $startTime.'－至－'.$endTime?></p>
				<div class="clearfix"></div>
				<p><?php the_excerpt();?></p>	
				<p><?php if(has_tag()){the_tags();} ?></p>
				<a href="<?php echo get_permalink();?>" class="btn">查看规则</a>
			</div>
		</li>
	</ul>
	<?php
		}
	}
	get_template_part( 'content', 'paging' );
	?>
</div>

<?php
get_footer();
?>